package com.itheima.server.exception;

import com.itheima.domain.vo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 阿鹏
 * @date 2021/1/24 21:57
 */
@ControllerAdvice
public class ExceptionResolverAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseEntity exceptionAdvice(Exception e){
        e.printStackTrace();
        return ResponseEntity.status(500).body(ErrorResult.error());
    }
}
